package day18.feifei.homework;

public class Third {

    public static void main(String[] args) throws InterruptedException {
        Thread thread1 = new Thread(new Print(true));
        Thread thread2 = new Thread(new Print(false));
        thread1.start();//1000
        Thread.sleep(100);//900
        thread2.start();//1000
    }
}
class Print extends Thread {
    private Boolean flag;

    public Print(Boolean flag) {
        this.flag = flag;
    }

    @Override
    public void run() {
        if (flag) {
            for (int i = 1; i <= 10; i++) {
                System.out.println(this.getName() + "----->" + i);
                try {
                    sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        } else if (!flag) {

            for (int i = 10; i >= 1; i--) {
                System.out.println(this.getName() + "----->" + i);
                try {
                    sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }

        }
    }
}
